package com.mocha.nezha.config;

import com.mocha.nezha.nezha.ParkDeviceBuilder;
import com.mocha.nezha.service.NezhaService;
import com.scshyzh.concurrent.MochaExecutorManager;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;


/**
 * @author: songkui
 * @since: 2024/3/21 00:47
 */
@Component
@Order(1)
@Slf4j
@AllArgsConstructor
public class StartInitialize implements ApplicationRunner {

    private final NezhaService nezhaService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        MochaExecutorManager.getInstance().start(8);
        ParkDeviceBuilder.builder()
                .poleMap(nezhaService.mapPoleVertex())
                .poleEdgeMap(nezhaService.mapPoleEdg())
                .cameraMap(nezhaService.mapCamera())
                .parkMap(nezhaService.parkList())
                .build()
                .verify().initialize();
    }

}
